from ctypes import CDLL,byref,create_string_buffer
from ctypes import cdll
from collections import defaultdict
from genericpath import exists
import os, shutil, io, sys
import os.path as osp
import json, time
import numpy as np
import cv2
import copy
import base64, requests
from multiprocessing import Pool
from tqdm import tqdm
from PIL import Image
from tool import filesystem, via_tool, darknet_tool, opencv_tool # export PYTHONPATH=$PYTHONPATH:`pwd`

def remove_two_plate(data_dir, two_plate_dir):
    total_files = filesystem.get_all_filepath(data_dir, [".jpg"])
    remove_files = filesystem.get_all_filepath(two_plate_dir, [".jpg"])
    remove_names = [osp.basename(f) for f in remove_files]
    save_dir = osp.join(data_dir, "two_plate")
    os.makedirs(save_dir, exist_ok=True)

    for f in total_files:
        name = osp.basename(f)
        if f not in remove_files and name in remove_names:
            print(f)
            shutil.move(f, osp.join(save_dir, osp.basename(f)))

if __name__ == "__main__":
    data_dir = r"F:\work\dataset\ocr\plate\CCPD2019"
    two_plate_dir = r"F:\work\dataset\ocr\plate\CCPD2019\two_plate_filter"
    remove_two_plate(data_dir, two_plate_dir)